<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  <body>

  </body>

  <script>
    /*if-else*/
    var people = {
        name:'chen',
        age:35,
        sex:'男'
    }
    if (people){//null为false
        console.log('这个人存在')

        if (people.age>30 && people.sex==='男'){
            console.log('这是一个大于三十岁的男人')
        }

        if (people.age>30 || people.sex==='女'){
            console.log('这个人大于三十岁或者是女人')
        }

        if (!(people.sex==='女')){
            console.log('这个人不是一个女人')
        }

        if (people.name!=='chen'){
            console.log('这个人不叫chen')
        }else if (people.age<20){
            console.log('这个人不小于20')
        }else {
            console.log('这个人满足我的要求')
        }
    }

    /*switch*/
    let number = 10;
    switch (number) {
        case 1:
            console.log('1');
            break;
        case 5:
            console.log('5');
            break;
        case 10:
            console.log('10');
            break;
        default:
            console.log('没有找到');
    }

    /*三元运算符*/
    let str = 'chen';
    console.log(str?'str不为空，值为'+str:'str为空')//str不为空，值为chen

    /*for*/
    var arr = ['hh','kk','ss','yy','xx'];
    for (let i = 0; i < arr.length; i++) {
        console.log(arr[i]);//hh，kk，ss，yy，xx
    }

    for (let i = 0; i < arr.length; i++) {
        if (i===3){
            break
        };
        console.log(arr[i]);//hh，kk，ss
    }

    for (let i = 0; i < arr.length; i++) {
        if (i===3){
            continue
        };
        console.log(arr[i]);//hh，kk，ss，xx
    }

    //表达式运算符中学习的in和of可以使用
    for (let index in arr) {
        console.log(index)//0，1，2，3，4
    }
    for (let value of arr) {
        console.log(value)//hh，kk，ss，yy，xx
    }

    /*while*/
    var arr = ['hh','kk','ss','yy','xx'];
    var index = 0;
    while (arr.length<=0){
        console.log(arr[index])//无输出
        index++;
    }

    /*do-while*/
    var arr = ['hh','kk','ss','yy','xx'];
    var index = 0;
    do {
        console.log(arr[index])//hh
        index++;
    }while ((arr.length<=0))
  </script>
</html>